var redis = require('redis'),
  logger = require('./logger'),
  conf = require('../../conf'),
  client = redis.createClient({
    host: conf.redis.host,
    port: conf.redis.port,
    password: conf.redis.password,
  });

var tagLogger = new logger.TagLogger('CARPLUS-REDIS');

client.on('ready', function(err) {
  tagLogger.info(`ready `);
});
client.on('connect', function(err) {
  tagLogger.info(`connect host:${conf.redis.host},port:${conf.redis.port}`);
});
client.on('reconnecting', function(err) {
  tagLogger.info(`reconnecting host:${conf.redis.host},port:${conf.redis.port}`);
});
client.on('error', function(err) {
  tagLogger.error('Error ' + err);
});
client.on('end', function(err) {
  tagLogger.info('end ' + err);
});

module.exports = client;
